<template>
  <div class="login-wrapper">
    <div class="modal">
      <div class="login-container">
        <el-image class="logo" :src="loginLogo"></el-image>
      </div>
      <div class="title" v-if="isWechat">
        <p class="message">1、点击右上角 ⋯ 按钮</p>
        <p class="message">2、选择在浏览器中打开</p>
      </div>
    </div>
  </div>
</template>

<script>

import loginLogo from '@/assets/svg/login.svg';

export default {
  name: 'downloadApp',
  data() {
    return {
      isWechat: false,
      loginLogo,
    }
  },
  mounted() {
    this.checkWechatOrNot();
  },
  methods: {
    handleCheck() {
      this.$api.getLatestApp().then((res) => {
        window.location.href = res.downloadUrl;
      })
    },
    checkWechatOrNot() {
      var ua = navigator.userAgent.toLowerCase();
      if (ua.match(/MicroMessenger/i) == "micromessenger") {
        //在微信中打开
        this.isWechat = true;
      } else {
        this.isWechat = false;
        this.handleCheck();
      }
    }
  }
}
</script>

<style lang="scss">
.login-wrapper {
  display: flex;
  background-color: #14c8d5;
  width: 100vw;
  height: 100vh;

  .modal {
    width: 80%;
    margin-top: 20%;
    margin-left: auto;
    margin-right: auto;
    padding: 50px;
    background-color: #14c8d5;
    border-radius: 4px;
    box-shadow: 0px 0px 10px 3px #14c8d5;

    .login-container {
      display: flex;
      margin-bottom: 10%;

      .logo {
        margin-left: auto;
        margin-right: auto;
        display: block;
        margin-top: 10%;
      }
    }

    .title {
      font-size: 20px;
      line-height: 1.5;
      text-align: left;
      margin-bottom: 30px;

      .message {
        color: #fff;
      }
    }

    .btn-login {
      width: 100%;
    }
  }
}
</style>
